Skip to content


ai  101  pytorch  classification  nvidia  cuda  install  tensorrt  yolo  ardupilot  None  ros2  dds  micro ros  xrce  sitl  plugin  SITL  debug  rangefinder  pymavlink  mavros  gazebo  distance sensor  system_time  timesync  cmake  gtest  ctest  cpp  c++  format  fmt  multithreading  spdlog  camera  coordinate system  orb  matching  opencv  build  transformation  computer vision  homography  optical flow  of  trackers  cv  cyclonedds  eprosima  fastdds  simulation  config  ignition  bridge  sdf  tips  ign-transport  sensors  lidar  aptly  apt  encryption  pgp  docker  git  bundle  github  hooks  pre-commit  lxd  container  lxc  x11  profile  vscode  marpit  presentation  marp  markdown  mermaid  video  ffmpeg  gstreamer  cheat-sheet  sdp  v4l2loopback  gi  snippets  cheat Sheet  python  asyncio  future  click  cli  numpy  project  template  black  isort  docs  project document  docstrings  flake8  linter  git-hook  mypy  unittest  pytest  pylint  mock  iterator  generator  logging  tuple  namedtuple  typing  annotation  pyzmq  zmq  msgpack  action  namespace  remap  control2  ros2_control  gdb  qos  tag  plugins  msg  node  zero-copy  shm  tutorial  algorithm  calibration  diff  pid  dev  colcon  colcon_cd  rpi  arm  qemu  settings  behavior  plot  visualization  debugging  diagnostic  diagnostics  tutorials  gst  math  apm  rat_runtime_monitor  web  rosbridge  vue  binding  discovery  gazebo-classic  launch  spawn  cook  gps  imu  ray  gazebo_ros_ray_sensor  ultrsonic  range  ultrasonic  gazebo classic  wrench  effort  odom  ign  gz  xacro  ros_ign  diff_drive  odometry  joint_state  argument  OpaqueFunction  DeclareLaunchArgument  LaunchConfiguration  tmux  nav  slam  test  rclpy  executor  MultiThreadedExecutor  SingleThreadedExecutor  param  dynamic-reconfigure  service  client  setup.py  package.xml  parameter  parameters  custom  msgs  executers  pub  sub  rqt  rviz  rviz2  pose  marker  tf2  deb  package  setup  local_setup  rosdep  package manager  project settings  vcstool  cross-compiler  nano  texture  tmuxp  rootfs  embedded  zah  linux  rm  ubuntu  ip  ss  network  netstat  snap  deploy  ssh  systemd  mkdocs  extensions  socat  networking  serial  udp  tc  mtu  select  px4  robotics  kalman_filter  kalman  filter  control  todo  vscode-ext  json  yaml  schema  yocto  poky  world  gazebo_ros2_control  position_controller  effort_controller  velocity_controller  urdf  gazebo_ros_force  gazebo_ros_joint_state_publisher  robot_state_publisher  joint_state_publisher  projects  vrx  buoyancy 

Gazebo color texture and meshes


Demo#

basic sdf#

model folder struct#

└── simple_box
    ├── model.config
    └── model.sdf

files#

model.config
<?xml version="1.0"?>
<model>
  <name>simple_box</name>
  <version>1.0</version>
  <sdf version="1.5">model.sdf</sdf>
  <author>
    <name></name>
    <email></email>
  </author>
  <description>
  </description>
</model> 
sdf
<?xml version='1.0'?>
<sdf version="1.4">
  <model name="simple_box">
    <pose>0 0 0.5 0 0 0</pose>
    <static>true</static>
    <link name="link">
      <inertial>
        <mass>1.0</mass>
        <inertia> <!-- inertias are tricky to compute -->
          <!-- http://gazebosim.org/tutorials?tut=inertia&cat=build_robot -->
          <ixx>0.083</ixx>       <!-- for a box: ixx = 0.083 * mass * (y*y + z*z) -->
          <ixy>0.0</ixy>         <!-- for a box: ixy = 0 -->
          <ixz>0.0</ixz>         <!-- for a box: ixz = 0 -->
          <iyy>0.083</iyy>       <!-- for a box: iyy = 0.083 * mass * (x*x + z*z) -->
          <iyz>0.0</iyz>         <!-- for a box: iyz = 0 -->
          <izz>0.083</izz>       <!-- for a box: izz = 0.083 * mass * (x*x + y*y) -->
        </inertia>
      </inertial>
      <collision name="collision">
        <geometry>
          <box>
            <size>1 1 1</size>
          </box>
        </geometry>
      </collision>
      <visual name="visual">
        <geometry>
          <box>
            <size>1 1 1</size>
          </box>
        </geometry>
      </visual>
    </link>
  </model>
</sdf>

predefine color#

  • using predefine script
<visual name="visual">
    <geometry>
        <box>
        <size>1 1 1</size>
        </box>
    </geometry>
    <material>
        <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Red</name>
        </script>
    </material>
</visual>

materials list

list of materials define in gazebo file /usr/share/gazebo-11/media/materials/scripts/gazebo.material for example the RED definition

material Gazebo/Red
{
technique
{
    pass ambient
    {
    ambient 1 0 0
    diffuse 1 0 0
    specular 0.1 0.1 0.1 1 1
    }
}
}


Custom color#

<visual name="visual">
    <geometry>
        <box>
        <size>1 1 1</size>
        </box>
    </geometry>
    <material> <!-- LED material -->
        <ambient>0 0 0 1</ambient>
        <diffuse>0 0 0 1</diffuse>
        <specular>0 0 0 0</specular>
        <emissive>0 1 0 1</emissive>
    </material> <!-- End LED material -->
</visual>


Texture#

└── simple_box
    ├── materials
    │   ├── scripts
    │   │   └── simple_box.material
    │   └── textures
    │       └── seamless_texture.png
    ├── model.config
    └── model.sdf
simple_box.material
material wood/light
{
  technique
  {
    pass
    {
      texture_unit
      {
        // Relative to the location of the material script
        texture ../textures/seamless_texture.png
        // Repeat the texture over the surface (4 per face)
        scale 0.5 0.5
      }
    }
  }
}
<visual name="visual">
    <geometry>
        <box>
        <size>1 1 1</size>
        </box>
    </geometry>
    <material>
        <script>
            <uri>file:///home/user/dev_ws/src/rrbot/rrbot_description/models/simple_box/materials/scripts</uri>
            <uri>file:///home/user/dev_ws/src/rrbot/rrbot_description/models/simple_box/materials/textures</uri>
            <name>wood/light</name>
        </script>
    </material>
</visual>

uri

use model uri and set GAZEBO_MODEL_PATH
or use file:// to set absolute path


stl mesh#

Warning

  • STL: does not support colors and texturing
  • Collada (.dae): support color and texture

stl color#

<visual name="visual">
    <geometry>
        <mesh>
        <uri>file:///home/user/dev_ws/src/rrbot/rrbot_description/models/simple_box/meshes/cube_20k.stl</uri>
        <scale>0.25 0.25 0.25</scale>
        </mesh>
    </geometry>
    <material>
        <script>
        <uri>file://media/materials/scripts/gazebo.material</uri>
        <name>Gazebo/Red</name>
    </script>
    </material>
</visual>

stl with texture#

<visual name="visual">
    <geometry>
        <mesh>
        <uri>file:///home/user/dev_ws/src/rrbot/rrbot_description/models/simple_box/meshes/cube_20k.stl</uri>
        <scale>0.5 0.5 0.5</scale>
        </mesh>
    </geometry>
    <material>
        <script>
        <uri>file:///home/user/dev_ws/src/rrbot/rrbot_description/models/simple_box/materials/scripts</uri>
        <uri>file:///home/user/dev_ws/src/rrbot/rrbot_description/models/simple_box/materials/textures</uri>
        <name>wood/light</name>
        </script>
    </material>
</visual>


Collada / dea#

Example from gazebo_models

library_images
<library_images>
    <image id="start_pad_png" name="start_pad_png">
        <init_from>end_pad.png</init_from>
    </image>
</library_images>


Reference#